< previous page page_352 next page >

Page 352
0352-01.jpg
Figure 15.8
Here's the 
CalcGeneral
Property Page with all its controls.
Implementing the SelectionChanged Event Procedure
Imagine for a moment that a developer is using the Calculator control as part of an application. The developer has placed two Calculator controls on a form, one for addition and the other for multiplication. When the developer displays the Property Pages dialog box for one or more of these user controls, the SelectionChanged event of the Property Page object fires so that each user control's current property settings can be displayed on the Property Page. To write code to load properties into the text box and combo box, open the code window for the CalcGeneral Property Page by double-clicking the Property Page object. Next, enter the lines of code from Listing 15.5 in the SelectionChanged event procedure.
Listing 15.5 CALC.ZIPThe SelectionChanged Event Procedure
Private Sub PropertyPage_SelectionChanged()

    txtCaption.Text = SelectedControls(0).Caption
    txtButtonCaption.Text = SelectedControls(0).ButtonCaption

    cmbOperation.Clear
    cmbOperation.AddItem "0 - Add"
    cmbOperation.AddItem "1 - Multiply"
    cmbOperation.AddItem "2 - Subtract"
    cmbOperation.AddItem "3 - Divide"
    cmbOperation.ListIndex = SelectedControls(0).Operation
    Changed = False
End Sub
Notice that each control on the Property Page is assigned a value from a property of a control in the SelectedControls collection. As you will see, Property Pages can modify the properties of several controls simultaneously. Currently, you've created a Property Page that can handle only a single control selection.
Implementing the Change Event Procedures
When a developer changes the value of a control on a form, the control's Change event is fired. For a Property Page, you use this event to notify Visual Basic that the contents of a property have changed.

 
< previous page page_352 next page >